package com.hengtongxing.hejiayun_employee.login;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;

import com.hengtongxing.hejiayun_employee.MainActivity;
import com.hengtongxing.hejiayun_employee.R;
import com.hengtongxing.hejiayun_employee.base.BaseActivity;
import com.hengtongxing.hejiayun_employee.dialog.PrivacyDialog;
import com.hengtongxing.hejiayun_employee.utils.SPManager;


public class SplashActivity extends BaseActivity {
    private Handler handler;
    private Runnable runnable;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);
        handler = new Handler();
        if (TextUtils.isEmpty(SPManager.getInstance().getProtocol())) {
            PrivacyDialog dialog = PrivacyDialog.newInstance();
            dialog.show(getSupportFragmentManager(), "dialog");
        } else {
            handler.postDelayed(runnable = new Runnable() {
                @Override
                public void run() {
                    if (!TextUtils.isEmpty(SPManager.getInstance().getToken()) && !TextUtils.isEmpty(SPManager.getInstance().getUserInfoJson())) {
                        Intent intent = new Intent(SplashActivity.this, MainActivity.class);
                        startActivity(intent);
                    } else {
                        Intent intent = new Intent(SplashActivity.this, LoginActivity.class);
                        startActivity(intent);
                    }

                    finish();
                }
            }, 1000);
        }
    }

}
